package com.jy.rhin.support.polymorphism.convertor;

import cn.org.chiss.rhin._2015.document.management.DocumentStoredQueryResponse;
import com.jy.rhin.sdk.dto.document.DocumentFolderDto;
import com.jy.rhin.sdk.dto.document.DocumentResultDto;
import com.jy.rhin.sdk.dto.document.query.FindFoldersDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author dhl
 * @date 2022/6/21
 * @Description
 */
@Service("findFolders")
public class DocumentQueryHandler4FindFolders extends AbstractDocumentQueryHandler<FindFoldersDto, DocumentFolderDto> {
    @Override
    FindFoldersDto convertReq(Map<String, List<String>> dtoValueMap) {
        FindFoldersDto dto = new FindFoldersDto();
        dto.setPatientId(QueryValueUtils.getStringValue("$FolderPatientId", dtoValueMap));
        dto.setStatusCodeList(QueryValueUtils.getListValue("$FolderStatus", dtoValueMap));
        dto.setLastUpdateTimeStart(QueryValueUtils.getDateValue("$FolderLastUpdateTimeFrom", dtoValueMap));
        dto.setLastUpdateTimeEnd(QueryValueUtils.getDateValue("$FolderLastUpdateTimeTo", dtoValueMap));
        dto.setTypeCodeList(QueryValueUtils.getListValue("$FolderCodeList", dtoValueMap));
        return dto;
    }

    @Override
    DocumentResultDto<DocumentFolderDto> query(FindFoldersDto dto) {
        return documentSubmissionQueryHandler.findFolders(dto);
    }

    @Override
    DocumentStoredQueryResponse convertResp(List<DocumentFolderDto> resultList, List<String> jsonTextList) {
        return folderConvert(resultList, jsonTextList);
    }
}
